﻿#If NETFX_CORE Then
Imports Windows.Security.Cryptography
Imports Windows.Security.Cryptography.Core
Imports Windows.Storage.Streams

Namespace Global.System.Cryptography.IO

    Public Class CryptoStream
        Inherits Stream
        Implements IDisposable

        Private m_baseStream As Stream

        Public ReadOnly Property BaseStream() As Stream
            Get
                Return Me.m_baseStream
            End Get
        End Property

        Public Overrides ReadOnly Property CanRead As Boolean
            Get
                Return Me.BaseStream.CanRead
            End Get
        End Property

        Public Overrides ReadOnly Property CanSeek As Boolean
            Get
                Return Me.BaseStream.CanSeek
            End Get
        End Property

        Public Overrides ReadOnly Property CanWrite As Boolean
            Get
                Return Me.BaseStream.CanWrite
            End Get
        End Property

        Public Overrides ReadOnly Property Length As Long
            Get
                Return Me.BaseStream.Length
            End Get
        End Property

        Public Overrides Property Position As Long
            Get
                Return Me.BaseStream.Position
            End Get
            Set(value As Long)
                Me.BaseStream.Position = value
            End Set
        End Property

        Public Sub New(ByVal baseStream As Stream)
            MyBase.New()
            Me.m_baseStream = baseStream
        End Sub

        Public Overrides Sub Flush()
            Me.BaseStream.Flush()
        End Sub

        Public Overrides Function Read(buffer() As Byte, offset As Integer, count As Integer) As Integer
            Return Me.BaseStream.Read(buffer, offset, count)
        End Function

        Public Overrides Function Seek(offset As Long, origin As SeekOrigin) As Long
            Return Me.BaseStream.Seek(offset, origin)
        End Function

        Public Overrides Sub SetLength(value As Long)
            Me.BaseStream.SetLength(value)
        End Sub

        Public Overrides Sub Write(buffer() As Byte, offset As Integer, count As Integer)
            Me.BaseStream.Write(buffer, offset, count)
        End Sub

    End Class

End Namespace

#End If